import 'package:finance_app/src/entities/chat_room_message_entity.dart';
import 'package:finance_app/src/utils/date_time_utils.dart';

chatRoomMessageEntityFromJson(ChatRoomMessageEntity data, Map<String, dynamic> json) {
	if (json['data_type'] != null) {
		data.dataType = json['data_type'].toString();
	}
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['chat_room_id'] != null) {
		data.chatRoomId = json['chat_room_id'] is String
				? int.tryParse(json['chat_room_id'])
				: json['chat_room_id'].toInt();
	}
	if (json['message_id'] != null) {
		data.messageId = json['message_id'] is String
				? int.tryParse(json['message_id'])
				: json['message_id'].toInt();
	}
	if (json['user_id'] != null) {
		data.userId = json['user_id'];
	}
	if (json['type'] != null) {
		data.type = json['type'].toString();
	}
	if (json['content'] != null) {
		data.content = json['content'].toString();
	}
	if (json['actions'] != null) {
		data.actions = json['actions'];
	}
	if (json['avatar'] != null) {
		data.avatar = json['avatar'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'];
	}
	if (json['created_at'] != null) {
		data.createdAt = json['created_at'].toString();
	}
	if (json['updated_at'] != null) {
		data.updatedAt = json['updated_at'].toString();
	}
	return data;
}

Map<String, dynamic> chatRoomMessageEntityToJson(ChatRoomMessageEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['data_type'] = entity.dataType;
	data['id'] = entity.id;
	data['chat_room_id'] = entity.chatRoomId;
	data['message_id'] = entity.messageId;
	data['user_id'] = entity.userId;
	data['type'] = entity.type;
	data['content'] = entity.content;
	data['actions'] = entity.actions;
	data['avatar'] = entity.avatar;
	data['name'] = entity.name;
	data['created_at'] = entity.createdAt;
	data['updated_at'] = entity.updatedAt;
	return data;
}